//
//  MediaController.m
//  Nurse
//
//  Created by RainSets on 8/29/14.
//  Copyright (c) 2014 Honeywell. All rights reserved.
//

#import "MediaController.h"
#import "PatientService.h"
#import "AddMediaViewController.h"
#import "MediaCell.h"

@interface MediaController ()
@property (weak, nonatomic) IBOutlet UITableView *tableVMediaContent;
- (IBAction)segmentChangeAction:(id)sender;


@end

@implementation MediaController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self setTitle:@"媒体库"];
    NSDictionary* patient = [[PatientService sharedInstance]currentPatient];
    self.pInfoView.txtPatientName.text = [patient valueForKey:@"姓名"];
    self.pInfoView.txtPatientID.text = [NSString stringWithFormat:@"住院号:%@",[patient valueForKey:@"住院号"]];
    self.pInfoView.txtBedNo.text = [NSString stringWithFormat:@"床位号:%@",[patient valueForKey:@"床位号"]];
    NSString*xb= [patient valueForKey:@"性别"];
    if ([xb isEqualToString:@"女"]) {
        self.pInfoView.imgxb.image=[UIImage imageNamed:@"gender-female2.png"];
    }
    else{
        self.pInfoView.imgxb.image=[UIImage imageNamed:@"gender-male2.png"];
    }
    
    [self setrightBarButtonItem:@""orImaged:@"head-icon_03.png" Event:@selector(rightBar_clicked:)];
    
    [_tableVMediaContent setDataSource:(id<UITableViewDataSource>)self];
    [_tableVMediaContent setDelegate:(id<UITableViewDelegate>)self];
    
    
}

-(void)rightBar_clicked:(id)sender{
    AddMediaViewController *addMediaVC = [[AddMediaViewController alloc] initWithNibName:@"AddMediaViewController" bundle:nil];
    [self.navigationController pushViewController:addMediaVC animated:YES];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}




-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    
    return 100.f;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return 10;
    
}


- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
	return UITableViewCellEditingStyleNone;
}

// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NSString *identify = @"MediaCell";
    //BedCell *cell = (BedCell *)[tableView  dequeueReusableCellWithIdentifier:identify];
    
    MediaCell *cell =(MediaCell*) [tableView  dequeueReusableCellWithIdentifier:identify];
    if (!cell ) {
        NSArray *ibs = [[NSBundle mainBundle] loadNibNamed:@"MediaCell" owner:self options:nil];
        cell = (MediaCell *)[ibs firstObject];
        // cell.selectionStyle = UITableViewCellSelectionStyleGray;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    
    
    
    
    return  cell;
}




- (IBAction)segmentChangeAction:(id)sender {
    UISegmentedControl *segCtr = (UISegmentedControl *)sender;
    DLog(@"segCtr seg===%d",[segCtr selectedSegmentIndex]);
    NSInteger indx = [segCtr selectedSegmentIndex];
    switch (indx) {
        case 0:
        {
            DLog(@"全部。。。。。。");
        }
            break;
        case 1:
        {
            DLog(@"图像。。。。。。");
        }
            break;
        case 2:
        {
            DLog(@"音频。。。。。。");
        }
            break;
        case 3:
        {
            DLog(@"视频。。。。。。");
        }
            break;
            
        default:
            break;
    }
}
@end
